package top.ooyyh.model;

public class Task {
    private static int NEXT_ID = 1;

    private int id;
    private int userId;
    private String title;
    private String description;
    private String dueDate; // yyyy-MM-dd
    private String status; // TODO, IN_PROGRESS, DONE
    private String priority; // LOW, MEDIUM, HIGH
    private String ownerUsername;

    public Task(int id, int userId, String title, String description, String dueDate, String status, String priority, String ownerUsername) {
        this.id = id;
        this.userId = userId;
        this.title = title;
        this.description = description;
        this.dueDate = dueDate;
        this.status = status;
        this.priority = priority;
        this.ownerUsername = ownerUsername;
    }

    // 用于新建任务（id自增，status默认TODO，priority默认MEDIUM）
    public Task(String title, String description, String dueDate, int userId, String ownerUsername) {
        this.id = NEXT_ID++;
        this.userId = userId;
        this.title = title;
        this.description = description;
        this.dueDate = dueDate;
        this.status = "TODO";
        this.priority = "MEDIUM";
        this.ownerUsername = ownerUsername;
    }

    public int getId() { return id; }
    public void setId(int id) { this.id = id; }
    public int getUserId() { return userId; }
    public void setUserId(int userId) { this.userId = userId; }
    public String getTitle() { return title; }
    public void setTitle(String title) { this.title = title; }
    public String getDescription() { return description; }
    public void setDescription(String description) { this.description = description; }
    public String getDueDate() { return dueDate; }
    public void setDueDate(String dueDate) { this.dueDate = dueDate; }
    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }
    public String getPriority() { return priority; }
    public void setPriority(String priority) { this.priority = priority; }
    public String getOwnerUsername() { return ownerUsername; }
    public void setOwnerUsername(String ownerUsername) { this.ownerUsername = ownerUsername; }

    @Override
    public String toString() {
        return String.format("#%d 题目: %s | 截止: %s | 状态: %s | 优先级: %s\n描述: %s\n拥有者: %s",
                id, title, dueDate == null ? "-" : dueDate, status, priority, description == null ? "-" : description, ownerUsername);
    }
}
